From: Chad Horohoe Date: Thu, 28 Aug 2008 01:09:40 +0000 (+0000) Subject: Add some caching to the group counts. X-Git-Tag: 1.31.0-rc.0~45605 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=7bc1f8796376ce03ce6698c4ba770be3ff8e42e4;p=lhc%2Fweb%2Fwiklou.git Add some caching to the group counts. --- diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 48df848710..e64a624653 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -114,9 +114,16 @@ class SiteStats { */ static function numberingroup($group) { if ( !isset( self::$groupMemberCounts[$group] ) ) { - $dbr = wfGetDB( DB_SLAVE ); - self::$groupMemberCounts[$group] = $dbr->selectField( 'user_groups', 'COUNT(*)', + global $wgMemc; + $key = wfMemcKey( 'SiteStats', 'groupcounts', $group ); + $hit = $wgMemc->get( $key ); + if ( !$hit ) { + $dbr = wfGetDB( DB_SLAVE ); + $hit = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => $group ), __METHOD__ ); + $wgMemc->set( $key, $hit, 3600 ); + } + self::$groupMemberCounts[$group] = $hit; } return self::$groupMemberCounts[$group]; }